import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { Button, Icon, SearchBar, NoticeBar, Swiper, SwiperItem, Menu, MenuItem, OverLay, Popup, Tabs, TabPane, List,
    Checkbox, Input, Divider, Cell, Picker, Uploader, Progress, Empty, DatePicker, CountDown, Cascader, Sticky, Dialog } from '@nutui/nutui-taro';
import { setStorageSync, removeStorageSync } from '@tarojs/taro'
import { getUrlParams } from '@/utils/helper'
// import { showShareMenu } from '@tarojs/taro'
import CdnImg from "@/components/CdnImg";
import './router/guard'
import './app.scss'

const cdn = 'https://static.douyintuoke.cn';
const App = createApp({
    onShow(options) {
        // 微信小程序监听路由变化
        // wx.onAppRoute(res => {
        //     console.log(111, res)
        // })
        const { from_id, q } = options.query
        if(from_id){
            console.log(111,from_id)
            setStorageSync('from_id', from_id)
        }
        if(q){
            const url = decodeURIComponent(q)
            const from_id = getUrlParams(url, 'from_id')
            setStorageSync('from_id', from_id)
            console.log(2222, from_id)
        }
    },
    // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
})

App.use(createPinia())
App.use(Button)
.use(Icon)
.use(SearchBar)
.use(NoticeBar)
.use(Swiper)
.use(SwiperItem)
.use(Menu)
.use(MenuItem)
.use(DatePicker)
.use(Picker)
.use(Popup)
.use(OverLay)
.use(Tabs)
.use(TabPane)
.use(List)
.use(Checkbox)
.use(Input)
.use(Divider)
.use(Cell)
.use(Uploader)
.use(Progress)
.use(Empty)
.use(CountDown)
.use(Cascader)
.use(Sticky)
.use(Dialog);
App.component('cdn-img', CdnImg)
// 全局注入
App.provide('cdn', cdn)
export default App
